<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>

<html>
<head>
    <jsp:include page="./util/configurationPage.jsp"/>
</head>
<body class="bg-body">
    <jsp:include page="./util/navbar/navbarMain.jsp"/>
    <br>
    <c:if test="${pageContext.request.userPrincipal.name == null}">
        <div class="alert alert-success text-center" role="alert">
            <h1><strong>Witamy!</strong><br>Zaloguj się aby móc korzystać z systemu SKB</h1>
        </div>
    </c:if>

	<sec:authorize access="hasRole('ROLE_USER') or hasRole('ROLE_ADMIN')">
		<!-- For login user -->
		<c:url value="/logout" var="logoutUrl" />
		<form action="${logoutUrl}" method="post" id="logoutForm">
			<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
		</form>
		<script>
			function formSubmit() {
				document.getElementById("logoutForm").submit();
			}
		</script>

		<c:if test="${pageContext.request.userPrincipal.name != null}">
            <div class="alert alert-success text-center" role="alert">
                <h1><strong>Witaj!</strong><br>${pageContext.request.userPrincipal.name}<br>
            </div>
            <!--
			<h2>
				Użytkownik : ${pageContext.request.userPrincipal.name} |
				<a href="javascript:formSubmit()"> Wyloguj</a> |
                <a href="../orbeon/fr/">Zarządzaj formularzami</a>
			</h2>
             -->
		</c:if>

	</sec:authorize>
    <jsp:include page="./util/footer.jsp"/>
</body>
</html>